package com.lej.core.binding.viewadapter.textview.view

import android.graphics.drawable.Drawable
import android.widget.TextView
import androidx.databinding.BindingAdapter


/**
 * requireAll 是意思是是否需要绑定全部参数, false为否
 * View的onClick事件绑定
 * onClickCommand 绑定的命令,
 * isThrottleFirst 是否开启防止过快点击
 */
@BindingAdapter(value = ["drawableStart"])
fun TextView.drawableStart(drawable: Drawable?) {
    setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
}

@BindingAdapter(value = ["drawableSize"])
fun TextView.drawableSize(sizeDp: Int) {
    compoundDrawables.forEach {
        it?.setBounds(0,0,sizeDp,sizeDp)
    }
    setCompoundDrawables(compoundDrawables[0],compoundDrawables[1],compoundDrawables[2],compoundDrawables[3])
}